<template>
  <div class="content">
    <!--    工艺模板列表弹窗-->
    <el-dialog
      v-dialogDrag
      :title="$t('market.craftList')"
      model
      :visible.sync="isclientlDialog"
      :close-on-click-modal="false"
      width="60%"
      :before-close="handleClose"
    >
      <div class="materiel-form">
        <search :options="selectData" :msg="tacitly" @seek="collect" @hand="clientSearch()" />
        <el-button size="mini" class="btn" type="primary" @click="clientSearch">{{ $t('btn.search') }}</el-button>
      </div>
      <jc-table
        :table-data="clientlDialogData"
        :table-header="clientDialogHeader"
        table-height="53vh"
        serial
        @clickRow="clientlSelectRow"
      />
      <jc-pagination
        v-show="client.total > 0"
        :total="client.total"
        :page.sync="client.pageNum"
        :limit.sync="client.pageSize"
        @pagination="queryTBdCustomerList"
      />
    </el-dialog>
  </div>
</template>
<script>
import { queryReviewWorkshopCraftList } from '@/api/engineering/createBom'
import { toMxBmina } from '@/components/ToMxamineState'
import search from '@/components/Search'
import searData from '@/components/Search/mixin'
export default {
  components: {
    search
  },
  mixins: [searData],
  props: {
    msg: {
      type: [String, Number],
      default: ''
    }
  },
  data() {
    return {
      ftype: 15,
      fbillNo: 'fname', // 销售订单号
      // 客户列表数据分页
      isclientlDialog: true,
      client: {
        total: 0, // 总条目
        pageNum: 1, // 当前页
        pageSize: 20 // 每页显示多少条数据
      },
      clientlDialogData: [],
      clientDialogHeader: [
        { label: this.$t('market.fcraftname'), prop: 'fname' },
        { label: this.$t('market.craftModel'), prop: 'fmodel' },
        { label: this.$t('market.totalSumPrice'), prop: 'totalSumPrice' },
        { label: this.$t('market.deaprt'), prop: 'fdeptName' },
        { label: this.$t('market.craftnumber'), prop: 'fnumber' },
        { label: this.$t('market.documentstatus'), prop: 'fdocumentstatus' },
        { label: this.$t('market.createDate'), prop: 'fcreateTime' }
      ],
      prodValue: { fcustId: '', fname: '', isclientlDialog: true }
    }
  },
  created() {
    this.queryTBdCustomerList()
  },
  methods: {
    // 获取客户列表
    async queryTBdCustomerList() {
      const DATA = {
        ...this.client,
        search: this.searCollData
      }
      const { data: RES } = await queryReviewWorkshopCraftList(DATA)
      this.clientlDialogData = RES.list.map(res => {
        return toMxBmina(res)
      })
      this.client.total = RES.total
    },
    // 客户弹窗选中
    clientlSelectRow(item) {
      this.$emit('client', item)
    },
    clientSearch() {
      this.client.pageNum = 1
      this.queryTBdCustomerList()
    },
    // 关闭前回调
    handleClose() {
      this.$emit('client', this.prodValue)
    }
  }
}
</script>

<style scoped lang="scss">
.content {
  @include listBom;
  .materiel-form{
    position: relative;
    bottom: 5px;
    .btn {
      transform: translateY(18%);
      margin-left: 450px !important;
    }
  }
}
</style>
